@extends('layout.blog')
@section('content')
    <div class="col-md-8 content-main">
        <div class="content-grid">

            <div class="content-grid-single">

                <div class="content-form">
                    <h3>写文章</h3>
                    <form action="/add" method="post">
                        {{csrf_field()}}
                        <p>标题</p>
                        <input type="text" name="title" required/>
                        <p>内容</p>
                        <textarea style="height: 300px;" name="content" id="editor"> </textarea>

                        {{-- 错误提示--}}
                        @include('layout.error')

                        <input type="submit" value="提交" style="float: right;"/>
                    </form>
                </div>
                <div class="comments">
                    <h3></h3>
                    <div class="comment-grid">

                        <div class="comment-info">
                            <h4></h4>
                            <p></p>
                            <h5></h5>

                        </div>
                        <div class="clearfix"></div>
                    </div>


                </div>
            </div>

        </div>
    </div>

@endsection

@section('js')

    <script type="text/javascript" src="/js/wangEditor.min.js"></script>

    <script>

        var editor = new wangEditor('editor');

        // 移除源码、代码插入菜单
         editor.config.menus = $.map(wangEditor.config.menus, function(item, key) {
             if (item === 'source') {
                 return null;
             }
             if (item === 'insertcode') {
                 return null;
             }

             return item;
         });


        // 上传图片地址
        editor.config.uploadImgUrl = '/upload';

        // 设置 headers
        editor.config.uploadHeaders = {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        };
        editor.create();



    </script>

@endsection

